package com.study.servlet;

import com.study.dao.CountryInfoDAO;
import com.study.dao.impl.CountryInfoDAOImpl;
import com.study.dto.CountDto;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @PackgeName: com.study.servlet
 * @ClassName: HomeServlet
 * @Author: 严志祥
 * Date: 2022-05-13 15:08
 * project name: web_project_medal
 * @Version:
 * @Description:
 */
@WebServlet("/homeServlet.let")
public class HomeServlet extends HttpServlet {
    private CountryInfoDAO dao = new CountryInfoDAOImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try{
            List<CountDto> list = dao.countMedal();
            req.setAttribute("list",list);
            req.getRequestDispatcher("/home.jsp").forward(req,resp);
        }catch (Exception e){
            throw new ServletException(e.getMessage(),e);
        }
    }
}
